Public Class ColumnarTranspositionCipherForm

    Private objColTransCipher As New ColumnarTranspositionCipherEngine

    Private Sub btnEncrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEncrypt.Click
        If Not txtPlaintext.Text.Trim = "" Or Not txtKey.Text.Trim = "" Then
            Try
                txtCiphertext.Text = objColTransCipher.Encrypt(txtPlaintext.Text.Trim, txtKey.Text.Trim)
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
        Else
            MessageBox.Show("Please fill your plain text or key!", "Require fill", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        End If
    End Sub

    Private Sub btnDecrypt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDecrypt.Click
        If Not txtCiphertext.Text.Trim = "" Or Not txtKey.Text.Trim = "" Then
            Try
                txtPlaintext.Text = objColTransCipher.Encrypt(txtCiphertext.Text.Trim, txtKey.Text.Trim)
            Catch ex As Exception
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            End Try
        Else
            MessageBox.Show("Please fill your cipher text or key!", "Require fill", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        End If
    End Sub
End Class
